<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>js根据时间进行排序</title>
  <script src="../utils/index.js"></script>
</head>

<body>
  <script>
    let arrList = [
      { id: 1, name: 'test1', score: 99, dateTime: '2024-03-25 13:51:03' },
      { id: 2, name: 'test2', score: 89, dateTime: '2024-03-24 23:01:52' },
      { id: 3, name: 'test3', score: 102, dateTime: '2024-03-15 01:51:12' },
      { id: 4, name: 'test4', score: 100, dateTime: '2024-03-23 10:30:39' },
      { id: 5, name: 'test5', score: 111, dateTime: '2024-03-23 11:21:42' },
    ]

    // console.log('升序：',compare(arrList, 'score'));  // 升序
    // console.log('降序：',compare(arrList, 'score', false));  // 降序

    // console.log('升序：', dateSort(arrList, 'dateTime')); // 升序
    // console.log('降序：', dateSort(arrList, 'dateTime', false)); // 降序

    let arrListTwo = [
      { id: 1, name: "test1", date: '2024-03-25', time: '10:20:12' },
      { id: 2, name: "test2", date: '2024-03-24', time: '22:19:31' },
      { id: 3, name: "test3", date: '2024-03-24', time: '20:45:17' },
      { id: 4, name: "test4", date: '2024-03-26', time: '09:36:22' },
      { id: 5, name: "test5", date: '2024-03-25', time: '14:10:46' },
      { id: 6, name: "test6", date: '2024-03-26', time: '08:27:38' },
    ]

    // console.log('升序：', dateSortTwo(arrListTwo, 'date', 'time')); // 升序
    console.log('降序：', dateSortTwo(arrListTwo, 'date', 'time', false)); // 降序


    let arrListThree = [
      { id: 1, name: 'test1', score: 99 },
      { id: 2, name: 'test2', score: 89 },
      { id: 3, name: 'test3', score: 88 },
      { id: 4, name: 'test4', score: 85 },
      { id: 5, name: 'test5', score: 96 },
      { id: 6, name: 'test6', score: 88 },
    ]

    parallelSorting(arrListThree, 'score');  // 升序
    // parallelSorting(arrListThree, 'score', false);  // 降序

    console.log('并列排序(升序)：', arrListThree);
    // console.log('并列排序(降序)：', arrListThree);

  </script>
</body>

</html>